package leader.service;

import java.util.List;
import java.util.Map;

import teacher.bean.Teacher;
import database.dao.MysqlCrud;

public class StatisticService {
	
	public int getCountOfDirectAward(Teacher teacher,int state) {
		int sum=0;
		String sql="select count(*) from award as acheve ,teacher as T where acheve.teaId = T.teaId and T.direction=? and acheve.state>'"+state+"'";
		String[] parameter={String.valueOf(teacher.getDirection())};
		MysqlCrud mysqlcurd=new MysqlCrud();
		List<Map> lists=mysqlcurd.SelectData(sql,parameter);
		Map map=lists.get(0);
		sum=Integer.parseInt(map.get(0).toString());
		return sum;
	}

	public int getCountOfDirectPaper(Teacher teacher,int state) {
		int sum=0;
		String sql="select count(*) from paper as acheve ,teacher as T where acheve.teaId = T.teaId and T.direction=? and acheve.state>'"+state+"'";
		String[] parameter={String.valueOf(teacher.getDirection())};
		MysqlCrud mysqlcurd=new MysqlCrud();
		List<Map> lists=mysqlcurd.SelectData(sql,parameter);
		Map map=lists.get(0);
		sum=Integer.parseInt(map.get(0).toString());
		return sum;
	}
	
	public int getCountOfDirectPatent(Teacher teacher,int state) {
		int sum=0;
		String sql="select count(*) from patent as acheve ,teacher as T where acheve.teaId = T.teaId and T.direction=? and acheve.examine>'"+state+"'";
		String[] parameter={String.valueOf(teacher.getDirection())};
		MysqlCrud mysqlcurd=new MysqlCrud();
		List<Map> lists=mysqlcurd.SelectData(sql,parameter);
		Map map=lists.get(0);
		sum=Integer.parseInt(map.get(0).toString());
		return sum;
	}
	
	
	public int getCountOfDirectProject(Teacher teacher,int state) {
		int sum=0;
		String sql="select count(*) from project as acheve ,teacher as T where acheve.teaId = T.teaId and T.direction=? and acheve.state>'"+state+"'";
		String[] parameter={String.valueOf(teacher.getDirection())};
		MysqlCrud mysqlcurd=new MysqlCrud();
		List<Map> lists=mysqlcurd.SelectData(sql,parameter);
		Map map=lists.get(0);
		sum=Integer.parseInt(map.get(0).toString());
		return sum;
	}
	
	public int getCountOfDirectTreatise(Teacher teacher,int state) {
		int sum=0;
		String sql="select count(*) from treatise as acheve ,teacher as T where acheve.teaId = T.teaId and T.direction=? and acheve.state>'"+state+"'";
		String[] parameter={String.valueOf(teacher.getDirection())};
		MysqlCrud mysqlcurd=new MysqlCrud();
		List<Map> lists=mysqlcurd.SelectData(sql,parameter);
		Map map=lists.get(0);
		sum=Integer.parseInt(map.get(0).toString());
		return sum;
	}
	

}
